<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

<ui:composition template="../templates/hub.xhtml">
	<ui:define name="titre"></ui:define>
	<ui:define name="hub_page">

		<!-- Inclusion du bloc de navigation simple. -->
		<ui:include src="../blocs/inc_navigation_message.xhtml" />

		<hr />
		<!-- Bandeau titre. -->
		<h:panelGrid style="width:100%;background-color:#808080">
			<h:outputText value="#{lbl['inputdata.title.form']}"
				style="color:#FFFFFF;font-weight:bold;" />
		</h:panelGrid>
		<p />

		<!-- Le panneau de chargement des fichiers. -->
		<h:form id="inputdata_form">
			<h:panelGrid id="inputdata_panel" columns="4"
				columnClasses="_left_top, _letf_top,_left_top, _letf_top">
				<h:panelGroup>
					<h:outputText value="#{lbl['inputdata.file.sillon']}" /> : 
				<p />
				</h:panelGroup>
				<rich:fileUpload id="file_upload_sillon" noDuplicate="true"
					fileUploadListener="#{inputDataFileManaged.sillonListener}"
					acceptedTypes="xls" addLabel="#{lbl['inputdata.add']}"
					maxFilesQuantity="5" clearLabel="#{lbl['inputdata.del']}"
					uploadLabel="#{lbl['inputdata.load']}"
					clearAllLabel="#{lbl['inputdata.del.all']}"
					clearAllControlLabel="#{lbl['inputdata.del.all']}"
					deleteLabel="#{lbl['inputdata.del']}">
					<a4j:ajax event="uploadcomplete" execute="@none"
						render="inputdata_panel_container" />
				</rich:fileUpload>

				<h:panelGroup>
					<h:outputText value="#{lbl['inputdata.file.composition']}" /> : 
				<p />
				</h:panelGroup>
				<rich:fileUpload id="file_upload_composition" noDuplicate="true"
					fileUploadListener="#{inputDataFileManaged.compositionListener}"
					acceptedTypes="xls" addLabel="#{lbl['inputdata.add']}"
					maxFilesQuantity="5" clearLabel="#{lbl['inputdata.del']}"
					uploadLabel="#{lbl['inputdata.load']}"
					clearAllLabel="#{lbl['inputdata.del.all']}"
					clearAllControlLabel="#{lbl['inputdata.del.all']}"
					deleteLabel="#{lbl['inputdata.del']}">
					<a4j:ajax event="uploadcomplete" execute="@none"
						render="inputdata_panel_container" />
				</rich:fileUpload>
			</h:panelGrid>
			<hr />

			<!-- Bandeau titre. -->
			<h:panelGrid style="width:100%;background-color:#808080">
				<h:outputText value="#{lbl['inputdata.title.list']}"
					style="color:#FFFFFF;font-weight:bold;" />
			</h:panelGrid>
			<p />

			<!-- Timer pour raffraîchir la liste des traitements. -->
			<a4j:poll action="#{inputDataFileManaged._getAllList}" enabled="true"
				render="inputdata_panel_container" interval="60000" />

			<!-- Le panneau pour la visualisation de la table de chargement. -->
			<h:panelGrid id="inputdata_panel_container" width="100%">
				<rich:dataTable value="#{inputDataFileManaged.lstInputData}"
					var="inputData" style="width:100%"
					rowClasses="rich_datagrid_even_line, rich_datagrid_odd_line"
					iterationStatusVar="it" id="inputData_table" styleClass="stable"
					rows="10">

					<f:facet name="noData">
						<h:outputText value="#{msg['msg.info.nodata']}" />
					</f:facet>

					<rich:column style="width:8%; text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['inputdata.date']}" />
						</f:facet>
						<h:outputText value="#{inputData.dateProcessing}">
							<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Europe/Paris" />
						</h:outputText>
					</rich:column>

					<rich:column style="width:15%; text-align:left">
						<f:facet name="header">
							<h:outputText value="#{lbl['inputdata.file.name']}" />
						</f:facet>
						<h:outputText value="#{inputData.fileAttachedName}" />
					</rich:column>

					<rich:column style="width:15%; text-align:left">
						<f:facet name="header">
							<h:outputText value="#{lbl['inputdata.file.store.name']}" />
						</f:facet>
						<h:commandLink action="#{inputDataFileManaged.downloadFile}">
							<h:outputText value="#{inputData.fileStoreName}"
								style="color:#000000;text-decoration: underline;" />
							<a4j:param name="fileName"
								assignTo="#{inputDataFileManaged.fileName}"
								value="#{inputData.fileStoreName}" />
						</h:commandLink>
					</rich:column>

					<rich:column style="width:30%;text-align:left">
						<f:facet name="header">
							<h:outputText value="#{lbl['inputdata.status']}" />
						</f:facet>
						<h:graphicImage value="../../imgs/icons/ico_timer.png"
							style="vertical-align:middle;"
							rendered="#{inputData.status == 'FILE_VALID'}" />
						<h:outputText value="#{inputData.statusLabel}" />
					</rich:column>

					<rich:column style="width:38%;text-align:left">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.message']}" />
						</f:facet>
						<h:outputText value="#{inputData.errorMessage}" />
					</rich:column>

					<rich:column style="width:4%; text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.delete']}" />
						</f:facet>

						<!-- Statut Traitement en cours. -->
						<a4j:commandLink execute="@this" render="del_panel"
							rendered="#{inputData.status ne 'CLOSE'}"
							oncomplete="#{rich:component('confirm_del_popup')}.show()">
							<h:graphicImage value="../../imgs/icons/ico_delete.png"
								width="20" />
							<f:setPropertyActionListener
								target="#{inputDataFileManaged.currentInputData}"
								value="#{inputData}" />
						</a4j:commandLink>

						<!-- Statut CLOSE. -->
						<h:graphicImage value="../../imgs/icons/ico_delete_disabled.png"
							width="20" rendered="#{inputData.status == 'CLOSE'}" />
					</rich:column>

					<f:facet name="footer">
						<rich:dataScroller page="#{userManaged.page}" />
					</f:facet>
				</rich:dataTable>
			</h:panelGrid>

			<!-- Pilotage des lignes tableau. -->
			<ui:include src="../blocs/inc_selector.xhtml" />

			<!-- Popup pour la suppression ligne chargement. -->
			<rich:popupPanel id="confirm_del_popup"
				headerClass="rich_panel_popup_head"
				header="#{lbl['inputdata.confirm']}" autosized="true">

				<h:panelGrid styleClass="panel" width="550" height="100"
					id="del_panel">
					<h:panelGroup>
						<h:outputText value="#{msg['msg.confirm.inputdata.delete']}" /> : 
						<h:outputText
							value="#{inputDataFileManaged.currentInputData.fileStoreName}" />  ?
					</h:panelGroup>
					<h:panelGrid columns="2" columnClasses="_left, _right" width="100%"
						style="margin-top:20px">
						<a4j:commandButton id="inputdata_b_cancel_delete"
							value="#{lbl['common.button.cancel']}"
							onclick="#{rich:component('confirm_del_popup')}.hide(); return false;" />

						<a4j:commandButton id="inputdata_b_delete"
							action="#{inputDataFileManaged.delete}"
							render="inputdata_panel_container" execute="@this"
							value="#{lbl['common.button.delete']}"
							oncomplete="#{rich:component('confirm_del_popup')}.hide();" />
					</h:panelGrid>
				</h:panelGrid>
			</rich:popupPanel>
		</h:form>
	</ui:define>
</ui:composition>
</html>